'*******************************************
' Always On Top Source code - by DarKPaiN
'
'w w w . P r o g e n i c . c o m
'*******************************************


'***********PLACE IN FORM************

Private Sub Form_Load()

	StayOnTop me, True
	'This will keep the current form
        'Ontop of every window
        'The boolean expression enables, and disables this!
End Sub

'***********PLACE IN MODULE************

Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
Public Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal Cx As Long, ByVal Cy As Long, ByVal wFlags As Long) As Long



Sub StayOnTop(frm As Form, TF As Boolean)
Dim success%
 If TF = True Then
    success% = SetWindowPos(frm.hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
 ElseIf TF = False Then
    success% = SetWindowPos(frm.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS)
 End If
End Sub